from celery import Celery
from django.core.mail import send_mail
import time
import os
import django

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "peanut_Django.settings")
django.setup()

# 构造可操作对象
app = Celery('celery_tasks.tasks', broker='redis://127.0.0.1:6379/5')


@app.task
def send_email_celery(to_email, active_id):
    subject = '花生二手车交易平台'
    message = ''
    from_email = 'xiameimei_win@163.com'
    recipient_list = [to_email]
    html_message = '<div><a href="http://localhost:8000/user/active/%s">这是激活邮件</a></div>' % active_id

    send_mail(subject=subject, message=message, from_email=from_email, recipient_list=recipient_list,
              html_message=html_message)

